﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows;
using System.Windows.Shapes;

namespace Snap
{
    public static class WinApiFunctions
    {
        [DllImport("user32.dll")]
        private static extern IntPtr GetForegroundWindow();

        [DllImport("user32.dll", SetLastError = true)]
        private static extern bool GetWindowRect(IntPtr hWnd, out Rectangle lpRect);

        [StructLayout(LayoutKind.Sequential)]
        public struct Rectangle
        {
            public int Left;
            public int Top;
            public int Right;
            public int Bottom;
        }

        public static Rect GetActiveWindowDimensions()
        {
            Rectangle area = new Rectangle();
            GetWindowRect(GetForegroundWindow(), out area);

            return new Rect(area.Left, area.Top, area.Right - area.Left, area.Bottom - area.Top);
        }
    }
}
